package d3_com.itheima.exception;


import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {

        while (true) {
            try {
                System.out.println(Test1());
                break;
            } catch (Exception e) {
                System.out.println("请您输入合法的数字~");
            }
        }
    }

    public static double Test1() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入一个合适的价格：");
            double insert = sc.nextDouble();
            if (insert >= 0) {
                return insert;
            } else {
                System.out.println("您输入的价格不合适~");
            }
        }
    }
}
